/**
 * Copyright © 2011 looty - Textoo
 * @link http://www.textoo.org
 * @link http://code.google.com/p/textoo/
 * @author lab9 - Bertrand Larrieu
 * @mail lab9.fr@gmail.com
 * @version 2.0
 */

package org.looty.core.textoo.render 
{
	import flash.display.*;
	import flash.text.*;
	import flash.utils.*;
	import org.looty.core.textoo.format.*;
	import org.looty.textoo.render.*;

	public class TextFieldRenderer extends AbstractTextooRenderer implements ITextooRenderer
	{
		
		private var _textFields			:Dictionary;
		
		public function TextFieldRenderer() 
		{		
			super(1);
			
			_textFields = new Dictionary(true);
		}
		
		private function getTextField(props:TextooProps):TextField
		{
			if (_textFields[props] == undefined) _textFields[props] = createTextField();			
			return _textFields[props];
		}
		
		public function render(props:TextooProps):RenderData 
		{
			var textField:TextField = createTextField();
			
			textField.text = "";
			
			applyProperties(textField, props);
			
			return new RenderData(Vector.<DisplayObject>([textField]));
		}
		
	}

}